<template>
  <div class="content_card">

    <van-row class="content_title" type="flex" justify="space-between">
      <van-col span="4" class="user_avatar">
        <van-image round cover :src="itemObj.avatar || logoImg" width="1.5rem" height="1.5rem"/>
      </van-col>
      <van-col span="20" class="user_nickname">
        <div>近聘昵称：{{itemObj.nick_name}}</div>
        <div style="margin: 5px 0;">近聘账号：<span style="margin-right: 6px; ">{{itemObj.ids}}</span></div>
<!--        <div style="margin: 5px 0;">性别：<span style="margin-right: 6px; ">{{itemObj.ids}}</span></div>   -->
        <div style="display: flex; justify-content: space-between; align-items: center; padding-right: 20px;">
          <span>手机号：{{(itemObj.mobile ? $hidePhone(itemObj.mobile) : '暂无')}}</span>
          <van-button size="mini" type="info" plain round @click.stop="callContact(itemObj.mobile)">电话联系</van-button>
        </div>
      </van-col>
    </van-row>

    <div v-show="$route.name === 'downstreamUsers'">

      <div>注册时间：{{itemObj.registertime || '无'}}</div>

      <div style="margin-top: 6px;text-align: left;" v-show="keyWord === 'showDSUsers'">
        <span >他推广的用户：</span>个人用户：<span style="font-weight: bolder; color: red; font-size: 13px">{{itemObj.personcount || 0}}</span>，
        企业用户：<span style="font-weight: bolder; color: red; font-size: 13px;">{{ itemObj.companycount || 0 }}</span>
      </div>

      <div style="margin-top: 18px; text-align: left; display: flex; align-items: center;" v-show="!(keyWord === 'showDSUsers')" >
        <span>二级服务追踪备注：</span>
        <textarea style="width: 180px; height: 50px" />
        <van-tag plain style="margin-left: 8px; padding: 5px;" type="primary" @click="toSubmitNote(itemObj)" >提交</van-tag>
      </div>

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
        v-if="keyWord === 'showDSUsers'"
      >
        <van-col span="8"><span >我获得的一级股份：</span></van-col>
        <van-col span="10">
          <div>已领取：<span style="font-weight: bolder; color: red; font-size: 13px">{{ itemObj.personcount || '0'}}</span></div>
          <div style="margin-top: 6px;">未领取：<span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px;">{{itemObj.companycount || '0'}}</span></div>
        </van-col>
<!--        <van-col span="6">
          <van-tag
            size="medium"
            type="primary"
            @click="handleLevelStockInfo(itemObj, 'L1')"
          >查看详情</van-tag>
        </van-col>-->
      </van-row>

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
        v-if="['L2', 'showDSUsers'].includes(keyWord)"
      >
        <van-col span="8"><span>我获得的二级股份：</span></van-col>
        <van-col span="10">
          <div>已领取：<span style="font-weight: bolder; color: red; font-size: 13px">{{ itemObj.personcount || '0'}}</span></div>
          <div style="margin-top: 6px;">未领取：<span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px;">{{itemObj.companycount || '0'}}</span></div>
        </van-col>
        <van-col span="6">
          <van-tag
            size="medium"
            type="primary"
            @click="handleLevelStockInfo(itemObj, 'L2')"
            v-if="['L2'].includes(keyWord)"
          >查看详情</van-tag>
        </van-col>
      </van-row>

      <!--  下游的企业用户才显示的部分    -->
      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left; vertical-align: center"
        v-show="itemObj.company_id"
      >
        <van-col span="24">
          <span >{{`${keyWord === 'showDSUsers' ? '一': '二'}`}}级推广用户发布招聘信息的总数：</span>
          <span style="font-weight: bolder; color: blue; font-size: 13px; margin-right: 20px">{{itemObj.jobcount || 0}}</span>
          <van-tag
            size="medium"
            color="#A701F0"
            @click="toCompanyPage(itemObj.company_id)"
          >前往查看</van-tag>
        </van-col>
      </van-row>
      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left; vertical-align: center"
        v-show="itemObj.company_id && keyWord === 'showDSUsers'"
      >
        <van-col span="24">
          <span >二级推广用户发布招聘信息的总数：</span>
          <span style="font-weight: bolder; color: blue; font-size: 13px; margin-right: 20px">{{itemObj.jobcount || 0}}</span>
        </van-col>
      </van-row>

      <div style="margin-top: 6px; padding-right: 6px; text-align: left;" v-show="itemObj.company_id">
        <div>企业资料：<van-tag size="medium" type="primary" @click.stop="toEnterpriseDetailPage(itemObj.company_id)">点击查看</van-tag></div>
      </div>



    </div>

<!--    <div v-show="$route.name === 'applyStockForHe'" >
      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
      >
        <van-col span="9">
          <span>他申请了
            <span style="font-size: 15px; font-weight: bolder; margin: 0 1px; color: red;">{{'22'}}</span>
            种股份：
          </span>
        </van-col>
        <van-col span="9">
          <div>理想的总价格：<span style="font-weight: bolder; color: red; font-size: 13px; margin-right: 3px">{{ itemObj.idealPrice || '0'}}</span>元</div>
          <div style="margin-top: 6px;">审核的总股份：
            <span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px; margin-right: 3px">
              {{itemObj.allStock || '0'}}
            </span>股
          </div>
        </van-col>
      </van-row>

    </div>-->

    <!--  申请股份数    -->
<!--    <van-row
      type="flex"
      style="margin-top: 10px; text-align: left;"
    >
      <van-col span="9">
          <span>他申请了
            <span style="font-size: 15px; font-weight: bolder; margin: 0 1px; color: red;">{{'22'}}</span>
            种股份：
          </span>
      </van-col>
      <van-col span="9">
        <div>理想的总价格：<span style="font-weight: bolder; color: red; font-size: 13px; margin-right: 3px">{{ itemObj.idealPrice || '0'}}</span>元</div>
        <div style="margin-top: 6px;">审核的总股份：
          <span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px; margin-right: 3px">
              {{itemObj.allStock || '0'}}
            </span>股
        </div>
      </van-col>
      <van-col span="4" v-show="!($route.name === 'applyStockForHe')">
        <van-tag
          size="medium"
          type="primary"
        >查看</van-tag>
      </van-col>
    </van-row>

    &lt;!&ndash;  未申请次数    &ndash;&gt;
    <van-row type="flex" justify="start" align="center" style="text-align: left" >
      <van-col span="12">
        <div>
          未申请次数：<span style="font-size: 16px; font-weight: bolder; margin: 0 1px; color: #FF976A;" >5</span><span style="margin-left: 6px;">次</span>
        </div>
      </van-col>
    </van-row>-->

  </div>
</template>

<script>
import logoImg from '@/assets/logo.png';
import {Toast} from "vant";

export default {
  name: "DSUsers",
  props: {
    itemObj: Object,
    // 显示与隐藏的标识, 值为: showDSUsers（点击进入详情后，顶部的上一个页面的一小部分）, L2, RP。这三种情况
    keyWord: String,
  },
  data() {
    return {
      logoImg,
      statusName: {
        Leave: '自离',
        Resign: '辞职',
        OnJob: '在职'
      },
    }
  },

  methods: {
    toSubmitNote(item){
      console.log('item', item);
    },

    callContact(mobile){
      if (mobile) window.location.href = 'tel:' + mobile;
    },

    toEnterpriseDetailPage(id) {
      console.log('点击对象的id', id)
      id && this.$router.push({
        path: `/enterpriseDetail/${id}`
      });
    },

    toCompanyPage(id) {
      Toast('前往公司');
      if(id){
        this.$router.push({
          path: `/company/${id}`
        })
      } else{
        Toast.fail('请稍等，正在获取数据！');
      }
    },

    handleLevelStockInfo(item={}, keyId){
      if(keyId === 'L2'){
        this.$parent.isShowAction = true;
      };

      /*this.$router.push({
        name: `applyStockForHe`,
        query: {
          id: item.id,
          avatar: item.avatar,
          nick_name: item.nick_name,
          mobile: item.mobile,
          ids: item.ids,
        }
      });*/

    },


  },
}
</script>

<style lang="scss" scoped>
.content_card{
  padding: 5px 5px 5px 10px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
  .content_title{
    .user_avatar{
    }
    .user_nickname {
      padding: 10px 0 0 10px;
    }
  }
  .content_reason{
    margin: 4px 0;
    .reason_text{
      border-bottom: 1px solid #F7F7F7;
      padding-bottom: 20px;
    }
  }
  .content_photo{
    padding-bottom: 1px;
    .content_pic{
      border-bottom: 1px solid #F7F7F7;
    }
  }
  .content_time{
    border-bottom: 1px solid #DEE1E6;
    padding-bottom: 4px;
    .apply_time{
      //vertical-align: center;
    }
  }
}
</style>
